import os.path
import time
import allure
import pytest
import requests
from .data import load_Registerdata,baseurl
basedir=os.path.dirname(__file__)
filepath=os.path.join(basedir,"testCase/register.json")
@allure.epic("注册接口")
class TestRegister:
    def setup_class(self):
        print("注册接口测试开始：",time.strftime("%Y-%m-%d-%H:%M:%S"))
    def teardown_class(self):
        print("注册接口测试结束：", time.strftime("%Y-%m-%d-%H:%M:%S"))
    @pytest.mark.parametrize("testCase,username,password,confirm_password,phone,status_code,msg,email,doctor_id",load_Registerdata(filepath))
    @allure.title("{testCase}")
    def test_Register(self,testCase,username,password,confirm_password,phone,status_code,msg,email,doctor_id):
        self.url=f"{baseurl}/register"
        data={
            "username":username,
            "password":password,
            "confirm_password":confirm_password,
            "phone":phone,
            "email":email,
            "doctor_id":doctor_id,
        }
        responses=requests.post(self.url,data=data)
        assert status_code==responses.status_code
        assert msg in responses.text

